﻿/*
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2009
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
*/

using System;
using MbUnit.Framework;
using WatiN.Core;
using DotNetNuke.Tests.UI.WatiN.Common;
using Gallio.Framework;
using DotNetNuke.Tests.UI.WatiN.Utilities;
using System.Configuration;
using WatiN.Core.DialogHandlers;
using DotNetNuke.Tests.UI.WatiN.Common.WatiNObjects;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;



namespace DotNetNuke.Tests.UI.WatiN.RegressionTests
{
    [TestFixture]


    public class FiveFourOneTests : RTBase
    {

        #region Test Setup and TearDown

        public bool LanguagePackInstalled = false;

        [SetUp]
        public void SetUp()
        {

        }

        [TearDown]
        public void TearDown()
        {
            if (LanguagePackInstalled)
            {
                WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
                LoginPage loginPage = new LoginPage(homePage);
                if (!homePage.RegisterLink.Text.Contains(TestUsers.Host.DisplayName))
                {
                    if (!homePage.RegisterLink.Text.Equals("Register"))
                    {
                        loginPage.LogoffUser();

                    }
                    loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
                }
                //Uninstall the language pack and delete the files
                ieInstance.GoTo(SiteURL + "/Host/Extensions.aspx");
                ExtensionsPage extensionsPage = new ExtensionsPage(homePage);
                extensionsPage.ExtensionPackageSelectList.Select("Core Language Pack");
                System.Threading.Thread.Sleep(2000);
                extensionsPage.GetExtensionUninstallButton(LocaleName).Click();
                System.Threading.Thread.Sleep(2000);
                extensionsPage.DeleteExtensionFilesCheckbox.Checked = true;
                ConfirmDialogHandler dialog = new ConfirmDialogHandler();
                using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
                {
                    extensionsPage.UninstallPackageLink.ClickNoWait();
                    dialog.WaitUntilExists();
                    dialog.OKButton.Click();
                }
                ieInstance.WaitForComplete();
                LanguagePackInstalled = false;
            }
            TearDownTest();
        }

        #endregion

        #region Tests

        [Test]
        public void DNN_12021_Clicking_A_User_In_Roles_Module_Causes_An_Exception()
        {
            SetUpTestForInstall();
            RunAutoInstall();

            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Add a user
            ieInstance.GoTo(SiteURL + "/Admin/UserAccounts.aspx");
            UserPage user = new UserPage(homePage);
            user.AddUser(TestUsers.User1.UserName, TestUsers.User1.Password, TestUsers.User1.FirstName, TestUsers.User1.LastName, TestUsers.User1.EmailAddress, TestUsers.User1.DisplayName);
            
            ieInstance.GoTo(SiteURL + "/Admin/SecurityRoles.aspx");
            SecurityRolesPage rolesPage = new SecurityRolesPage(homePage);
            rolesPage.GetManageUsersButton("Registered Users").Click();

            //Act 
            rolesPage.GetUserLinkFromUserRolesPage(TestUsers.User1.DisplayName).Click();

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbLink.Text.Contains("User Profile"));
            Assert.IsTrue(homePage.ModuleTitleSpan.Text.Contains("My Profile"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains(TestUsers.User1.DisplayName));
        }

        [Test]
        public void DNN_12224_Multiple_Portals_Appears_In_Portals()
        {
            SetUpTestForInstall();
            RunAutoInstall();

            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            ieInstance.GoTo(SiteURL + "/Host/Portals.aspx");
            HostPortalPage portals = new HostPortalPage(homePage);

            portals.AddNewPortalLink.Click();
            portals.ChildRadioButton.Click();
            System.Threading.Thread.Sleep(2000);
            portals.PortalAliasField.Value = ("localhost/" + ApplicationName + "/ChildPortal");
            portals.PortalTitle.Value = "Child Portal";
            portals.PortalTemplateSelect.Select("Default Website");
            System.Threading.Thread.Sleep(4000);
            portals.AdminUserNameField.Value = TestUsers.Admin2.UserName;
            portals.AdminFirstNameField.Value = TestUsers.Admin2.FirstName;
            portals.AdminLastNameField.Value = TestUsers.Admin2.LastName;
            portals.AdminEmailField.Value = TestUsers.Admin2.Email;
            portals.AdminPasswordField.Value = TestUsers.Admin2.Password;
            portals.AdminConfirmField.Value = TestUsers.Admin2.Password;
            portals.CreatePortalLink.Click();
            System.Threading.Thread.Sleep(7000);

            //Assert
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("There was an error sending confirmation emails - The EmailAddress address (support@localhost) is not in a valid format.. However, the website was created."));
            portals.MessageLink.Click();

            ieInstance.GoTo(SiteURL + "/childportal/Host/Portals.aspx");
            System.Threading.Thread.Sleep(2000);
            TableCell portalNumber = portals.GetPortalNumberCellByPortalName("Child Portal");
            TableCell portalTitle = portals.GetPortalTitleCellByPortalName("Child Portal");
            Assert.IsTrue(portalNumber.InnerHtml.Contains("1"));
            Assert.IsTrue(portalTitle.InnerHtml.Contains("Child Portal"));
        }

        [Test]
        public void DNN_12254_Portal_Zero_Disappears_When_Using_Non_US_Language()
        {
            SetUpTestForInstall();
            RunAutoInstall();
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);

            //Delete any files in the test EmailAddress folder
            homePage.DeleteFilesInTestEmails();
            
            //Edit the web.config file so that Emails are sent to a local folder
            WebConfigManager.UpdateConfig(PhysicalPath);

            //Arrange
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ieInstance.GoTo(SiteURL + "/tabid/16/portalid/0/Default.aspx");
            HostSettingsPage hostSettings = new HostSettingsPage(homePage);
            hostSettings.SetSMTPSettings("test@dnn.com", "localhost");

            //Act
            //Install a language
            ieInstance.GoTo(SiteURL + "/Admin/Extensions.aspx");
            ExtensionsPage extensionsPage = new ExtensionsPage(homePage);
            extensionsPage.InstallExtension(LanguagePath);
            LanguagePackInstalled = true;

            //Create a portal
            HostPortalPage portals = new HostPortalPage(homePage);
            ieInstance.GoTo(SiteURL + "/Host/Portals.aspx");
            portals.AddChildPortal(ApplicationName, "Child Portal", "ChildPortal");
            System.Threading.Thread.Sleep(3000);

            ieInstance.GoTo(SiteURL + "/Host/Portals.aspx");

            //Assert
            TableCell portalNumber = portals.GetPortalNumberCellByPortalName("Child Portal");
            TableCell portalTitle = portals.GetPortalTitleCellByPortalName("Child Portal");
            Assert.IsTrue(portalNumber.InnerHtml.Contains("1"));
            Assert.IsTrue(portalTitle.InnerHtml.Contains("Child Portal"));
            portalNumber = portals.GetPortalNumberCellByPortalName("My Website");
            portalTitle = portals.GetPortalTitleCellByPortalName("My Website");
            Assert.IsTrue(portalNumber.InnerHtml.Contains("0"));
            Assert.IsTrue(portalTitle.InnerHtml.Contains("My Website"));
        }

        [Test]
        public void DNN_12257_Adding_New_Languages_Kills_DNN_Corrupts_Cookie()
        {
            SetUpTestForInstall();
            RunAutoInstall();

            //Edit the web.config file so that Emails are sent to a local folder
            WebConfigManager.UpdateConfig(PhysicalPath);

            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            LanguagePage language = new LanguagePage(homePage);

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Languages.aspx");
            language.AddNewLanguage(LocaleName, "English (United States)");
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            System.Threading.Thread.Sleep(1500);
            Span flagSpan = language.GetLanguageFlagSpanByLocaleName(LocaleName);
            Image flag = flagSpan.Image(Find.ByAlt(LanguageCode));
            flag.Click();

            //Assert 
            Assert.IsTrue(ieInstance.Url.Contains(LanguageCode));
            Assert.IsFalse(homePage.ErrorImage.Exists);
        }

        [Test]
        public void DNN_12270_NullReference_In_New_AddScriptManage()
        {
            //Arrange
            //Set up a 493 site
            SetUpgradeVersionAndType("493", "1");
            SetUpSiteForUpgrade();

            //Shut down Ie
            ieInstance.GoTo(SiteURL + "/LogOff.aspx");
            WatiNUtil.CloseIEInstance(ieInstance);

            //Act
            //Run the upgrade
            RunUpgrade();

            //Clear cache and cookies
            ieInstance.ClearCookies(SiteURL);
            ieInstance.ClearCache();

            //Log in as host 
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ieInstance.GoTo(SiteURL + "/tabid/16/portalid/0/Default.aspx");
            SelectRibbonBarAsControlPanelStyle(TestUsers.Host.Email, homePage);

            //Add a page with a module on it 
            System.Threading.Thread.Sleep(2000);
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            RibbonBar ribbonBar = new RibbonBar(homePage);
            ribbonBar.NewPageLink.Click();
            PageSettingsPage pageSettings = new PageSettingsPage(homePage);
            pageSettings.AddPage("Test Page");

            //Edit the HTML module
            ModulePage module = new ModulePage(homePage);
            module.GetEditModuleContentLink(0).Click();

            //Assert
            Assert.IsTrue(homePage.FckEditorScriptElement.Exists);
            //Assert.IsFalse(homePage.TelerikEditorScriptElement.Exists);
            Assert.IsTrue(false);
        }

        [Test]
        public void DNN_12278_DNN_540_Appears_Like_An_Alpha_Version()
        {
            //Arrange
            SetUpTestForInstall();
            RunAutoInstall();

            //Assert
            Assert.IsFalse(ieInstance.Title.Contains("Beta"));
            Assert.IsFalse(ieInstance.Title.Contains("Alpha"));
        }

        [Test]
        public void DNN_12279_Release_Notes_Not_Included_In_540_Install()
        {
            //Arrange
            SetUpTestForInstall();
            RunAutoInstall();

            //Log in as host 
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Act 
            ieInstance.GoTo(SiteURL + "/Host/WhatsNew.aspx");

            //Assert
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("What's New in " + TestVersion));            
        }

        [Test]
        public void DNN_12279_Release_Notes_Not_Included_In_540_Upgrade()
        {
            //Arrange
            SetUpgradeVersionAndType("510", "1");
            SetUpSiteForUpgrade();
            ieInstance.Close();

            //Act 
            RunUpgrade();

            //Log in as host 
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Act 
            ieInstance.GoTo(SiteURL + "/Host/WhatsNew.aspx");

            //Assert
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("What's New in " + TestVersion));
        }

        [Test]
        public void DNN_12280_Profile_And_User_Mails_Sent_From_User_Not_Portal_Email_Address()
        {
            //Arrange
            SetUpTestForInstall();
            RunAutoInstall();

            //Edit the web.config file so that Emails are sent to a local folder
            WebConfigManager.UpdateConfig(PhysicalPath);

            //Log in as host 
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Configure Email
            ieInstance.GoTo(SiteURL + "/tabid/16/portalid/0/Default.aspx");
            HostSettingsPage hostSettings = new HostSettingsPage(homePage);
            hostSettings.SetSMTPSettings("test@dnn.com", "localhost");

            //Add 2 Users
            ieInstance.GoTo(SiteURL + "/Admin/UserAccounts.aspx");
            UserPage userPage = new UserPage(homePage);
            userPage.AddUser(TestUsers.User1.UserName, TestUsers.User1.Password, TestUsers.User1.FirstName, TestUsers.User1.LastName, TestUsers.User1.EmailAddress, TestUsers.User1.DisplayName);
            System.Threading.Thread.Sleep(3000);
            userPage.AddUser(TestUsers.User2.UserName, TestUsers.User2.Password, TestUsers.User2.FirstName, TestUsers.User2.LastName, TestUsers.User2.EmailAddress, TestUsers.User2.DisplayName);
            System.Threading.Thread.Sleep(2000);

            //Delete any files in the test EmailAddress folder
            homePage.DeleteFilesInTestEmails();
            
            //Add a role
            ieInstance.GoTo(SiteURL + "/Admin/SecurityRoles.aspx");
            SecurityRolesPage rolesPage = new SecurityRolesPage(homePage);
            rolesPage.AddRole("Test Role");

            //Act
            //Add a user to the role
            rolesPage.AddUserToRole("Test Role", TestUsers.User1.DisplayName);
            System.Threading.Thread.Sleep(2000);

            //Log in as a new user and edit their profile
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            loginPage.LogoffUser();
            loginPage.LoginUser(TestUsers.User2.UserName, TestUsers.User2.Password);
            loginPage.RegisterLink.Click();

            UserProfilePage profilePage = new UserProfilePage(homePage);
            profilePage.EditProfileLink.Click();
            profilePage.StreetField.Value = "A Street";
            profilePage.ProfileUpdateLink.Click();

            //Assert
            System.Threading.Thread.Sleep(2000);
            String emailFileName = null;
            String emailContent = null;
            int user1EmailFilePosition = 0;
            int user2EmailFilePosition = 0;
            for (int i = 0; i < Directory.GetFiles(TestEmailPath).Length; i++)
            {
                emailFileName = Directory.GetFiles(TestEmailPath)[i];
                emailContent = File.ReadAllText(emailFileName);
                if (emailContent.Contains("X-Receiver: " + TestUsers.User2.EmailAddress) && emailContent.Contains("Sender: " + TestUsers.Admin.Email))
                {
                    user2EmailFilePosition = i;
                }
                else if (emailContent.Contains("X-Receiver: " + TestUsers.User1.EmailAddress) && emailContent.Contains("Sender: " + TestUsers.Admin.Email))
                {
                    user1EmailFilePosition = i;
                }
            }

            //Check the content of the role EmailAddress sent to User 1
            emailFileName = Directory.GetFiles(TestEmailPath)[user1EmailFilePosition];
            emailContent = File.ReadAllText(emailFileName);
            emailContent = ConvertEmailContentFromBase64ToUnicode(emailContent, emailFileName);

            Assert.IsTrue(emailContent.Contains("Dear " + TestUsers.User1.DisplayName));
            Assert.IsTrue(emailContent.Contains("Your user account at My Website has been recently updated to include access to the following Security Role:"));
            Assert.IsTrue(emailContent.Contains("Test Role"));

            //Check the content of the updated profile EmailAddress sent to User 2
            emailFileName = Directory.GetFiles(TestEmailPath)[user2EmailFilePosition];
            emailContent = File.ReadAllText(emailFileName);
            emailContent = ConvertEmailContentFromBase64ToUnicode(emailContent, emailFileName);

            Assert.IsTrue(emailContent.Contains("Dear " + TestUsers.User2.DisplayName));
            Assert.IsTrue(emailContent.Contains("Your profile on My Website has been successfully updated."));
        }

        [Test]
        public void DNN_12289_CE_Banner_Missing_When_Admin_logged_In()
        {
            //Arrange
            SetUpTestForInstall();
            RunAutoInstall();

            //Act
            //Log in as the admin
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);

            //Assert 
            RibbonBar ribbonBar = new RibbonBar(homePage);
            Assert.IsTrue(ribbonBar.CommunityRibbonBarHeaderImage.Exists);
        }

        [Test]
        public void DNN_12297_Enabling_NonUS_Language_Causes_DNN_Logo_To_Disappear()
        {
            //Arrange
            SetUpTestForInstall();
            RunAutoInstall();

            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Install a language
            ieInstance.GoTo(SiteURL + "/Admin/Extensions.aspx");
            ExtensionsPage extensions = new ExtensionsPage(homePage);
            extensions.InstallExtension(LanguagePath);
            System.Threading.Thread.Sleep(1000);

            //Assert
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            Assert.IsTrue(homePage.LogoImage.Exists);
            Assert.IsTrue(homePage.LoginLink.Exists);
        }

        [Test]
        public void DNN_12303_Dual_Cancel_Buttons_On_Add_New_User_Screen()
        {
            //Arrange
            SetUpTestForInstall();
            RunAutoInstall();

            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/UserAccounts.aspx");
            UserPage userPage = new UserPage(homePage);
            userPage.AddNewUserStartLink.Click();

            //Assert
            Assert.IsTrue(homePage.ContentPane.Links.Filter(Find.ByTitle("Add New User")).Count == 1);
            Assert.IsTrue(homePage.ContentPane.Links.Filter(Find.ByTitle("Cancel")).Count == 1);
        }

        [Test]
        public void DNN_12309_Languages_Break_Administrator_User_In_Child_Portals()
        {
            //Arrange
            SetUpTestForInstall();
            RunAutoInstall();

            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Act
            //Add two languages
            ieInstance.GoTo(SiteURL + "/Admin/Languages.aspx");
            LanguagePage languagePage = new LanguagePage(homePage);
            languagePage.AddNewLanguage(LocaleName, "English (United States)");
            System.Threading.Thread.Sleep(1000);
            languagePage.AddNewLanguage("Deutsch (Deutschland)", "English (United States)");
            System.Threading.Thread.Sleep(2000);

            //Disable one language
            languagePage.GetCheckBoxForLanguage("German (Germany)", "Enabled").Checked = false;
            System.Threading.Thread.Sleep(3000);

            //Add a Child Portal
            ieInstance.GoTo(SiteURL + "/Host/Portals.aspx");
            HostPortalPage portals = new HostPortalPage(homePage);
            portals.AddChildPortal(ApplicationName, "Child Portal", "ChildPortal");
            System.Threading.Thread.Sleep(8000);

            SiteMenu menu = new SiteMenu(homePage);
            menu.MenuAdminSpan.FireEvent("onmouseover");
            menu.LanguagesSpan.Click();
            
            //Check that both languages are enabled
            Assert.IsTrue(languagePage.GetCheckBoxForLanguage("German (Germany)", "Enabled").Checked == true);
            Assert.IsTrue(languagePage.GetCheckBoxForLanguage(EnglishLocaleName, "Enabled").Checked == true);

            //Assert
            ieInstance.GoTo(SiteURL + "/ChildPortal/Home.aspx");
            loginPage.LogoffUser();
            loginPage.LoginLink.Click();

            Image frenchFlag = ieInstance.Image(Find.ByAlt(LanguageCode));
            frenchFlag.Click();
            Assert.IsTrue(ieInstance.Url.Contains(LanguageCode));

            loginPage.LoginUserNoGoTo(TestUsers.Admin2.UserName, TestUsers.Admin2.Password);
            Assert.AreEqual(TestUsers.Admin2.DisplayName, homePage.RegisterLink.Text);
            loginPage.LogoffUser();

            Image germanFlag = ieInstance.Image(Find.ByAlt("de-DE"));
            germanFlag.Click();
            loginPage.LoginUserNoGoTo(TestUsers.Admin2.UserName, TestUsers.Admin2.Password);
            Assert.AreEqual(TestUsers.Admin2.DisplayName, homePage.RegisterLink.Text);
            loginPage.LogoffUser();

            Image USFlag = ieInstance.Image(Find.ByAlt("en-US"));
            USFlag.Click();
            loginPage.LoginUserNoGoTo(TestUsers.Admin2.UserName, TestUsers.Admin2.Password);
            Assert.AreEqual(TestUsers.Admin2.DisplayName, homePage.RegisterLink.Text);
            loginPage.LogoffUser();
        }

        #endregion


        private string ConvertEmailContentFromBase64ToUnicode(string emailContent, string emailFileName)
        {
            //Replace any new link characters
            emailContent.Replace(Environment.NewLine, " ");
            
            //Separate the EmailAddress content from the EmailAddress information
            string contentLineRegex = "(?<=base64).*$";
            Match match = Regex.Match(@emailContent, contentLineRegex, RegexOptions.Singleline);
            Assert.IsTrue(match.Success, "Could not find content Line! Looking in file: " + emailFileName);
            
            //Convert the EmailAddress content
            emailContent = match.Value;
            byte[] b = System.Convert.FromBase64String(emailContent);
            String decodedEmailContent = System.Text.ASCIIEncoding.ASCII.GetString(b);
            return decodedEmailContent;
        }


        private void SelectRibbonBarAsControlPanelStyle(string hostEmail, WatiNBase homePage)
        {
            HostSettingsPage hostSettings = new HostSettingsPage(homePage);
            hostSettings.HostEmailTextField.Value = hostEmail;
            hostSettings.OtherSettingsExpandButton.Click();
            hostSettings.ControlPanelStyleSelectList.Select("RIBBONBAR");
            hostSettings.UpdateLink.Click();
            System.Threading.Thread.Sleep(1000);
        }


    }
}